﻿using System;
using System.Collections.Generic;
using System.Text;
using Task.Common.Interface;



namespace Task.Logic
{
    class DictionaryLogic:IDictionary
    {
        /// <summary>
        /// 获取数据
        /// </summary>
        /// <param name="statename">查询语句</param>
        /// <param name="where">查询条件</param>
        /// <returns></returns>
        public System.Collections.IList GetDictionaryList(string statename,string where)
        {
            System.Collections.Hashtable table = new System.Collections.Hashtable();
            //table.Add("taskid", "05041162c187f3a8e84ba5df1f54be");//参数--条件
            //查询条件的形式 为 [表字段名=参数值; ...]
            if (!String.IsNullOrEmpty(where))
            {
                where = where.TrimEnd(';');//格式化 条件 语句
                string[] strWheres = where.Split(';');//
                for (int i = 0; i < strWheres.Length; i++)
                {
                    string str = strWheres[i];
                    string[] strParems = str.Split('!');
                    table.Add(strParems[0], strParems[1]);//参数 将参数信息添加到hashtable中
                }
            }
            System.Collections.IList list = DataHelper.Instance().GetList(statename, table);
            return list;
        }


        public System.Data.DataSet GetDictionaryData(string statename, string where)
        {
            System.Collections.Hashtable table = new System.Collections.Hashtable();
            //table.Add("taskid", "05041162c187f3a8e84ba5df1f54be");//参数--条件
            //查询条件的形式 为 [表字段名=参数值; ...]
            if (!String.IsNullOrEmpty(where))
            {
                where = where.TrimEnd(';');//格式化 条件 语句
                string[] strWheres = where.Split(';');//
                for (int i = 0; i < strWheres.Length; i++)
                {
                    string str = strWheres[i];
                    string[] strParems = str.Split('!');
                    table.Add(strParems[0], strParems[1]);//参数 将参数信息添加到hashtable中
                }
            }
            System.Data.DataSet ds = DataHelper.Instance().GetDataSet(statename, table);
            return ds;
        }
    }
}
